package com.lz.autotest.project.testmanage.reportmanage.service.impl;

import com.lz.autotest.project.testmanage.reportmanage.domain.SstInfReport;
import com.lz.autotest.project.testmanage.reportmanage.mapper.ReportMapper;
import com.lz.autotest.project.testmanage.reportmanage.service.IReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 参数配置 服务层实现
 *
 * @author lz
 */
@Service
public class ReportServiceImpl implements IReportService {
    @Autowired
    private ReportMapper reportMapper;

    /**
     * 查询参数配置信息
     *
     * @param sstInfReport 参数配置ID
     * @return 参数配置信息
     */
    @Override
    public SstInfReport selectReportById(SstInfReport sstInfReport) {
        return reportMapper.selectReportById(sstInfReport);
    }

    /**
     * @param
     * @return 参数配置集合
     */
    @Override
    public List<SstInfReport> selectReportList(SstInfReport sstInfReport) {
        List<SstInfReport> reports = reportMapper.selectReportList(sstInfReport);
        for (SstInfReport report : reports) {
            if ("0".equalsIgnoreCase(report.getStatus())) {
                report.setPercentage(report.getSuccessCount() / report.getCount() * 100);
            }
        }
        return reports;
    }


    /**
     * 批量删除参数信息
     *
     * @param
     */
    @Override
    public void deleteReportByIds(Long[] reportIds) {

        reportMapper.deleteReportByIds(reportIds);

    }

}
